<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>将CSR作为字符串导出</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.openssl-csr-export" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_csr_export</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">openssl_csr_export</span> &mdash; <span class="dc-title">将CSR作为字符串导出</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.openssl-csr-export-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_csr_export</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$csr</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$out</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$notext</code><span class="initializer"> = true</span></span>
  ] ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>openssl_csr_export()</strong></span>  获取证书签名请求(<code class="parameter">csr</code>)并通过引用保存其 PEM 格式的字符串(<code class="parameter">out</code>)。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-csr-export-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

     
 <dt>
<code class="parameter">csr</code></dt>

 <dd>

  <p class="para">
   See <a href="openssl.certparams.html" class="link">CSR parameters</a> for a list of valid values.
  </p>
 </dd>


    
     <dt>
<code class="parameter">out</code></dt>

     <dd>

      <p class="para">
      在成功时，该字符串将包含PEM编码的CSR.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">notext</code></dt>

     <dd>

      <p class="para">
可选参数 <code class="parameter">notext</code> 影响输出的冗余度。如果设为
<strong><code>FALSE</code></strong>，输出内容将包含附加的人类可读信息。<code class="parameter">notext</code> 的缺省值为 <strong><code>TRUE</code></strong>。
</p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-csr-export-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.openssl-csr-export-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-924">
    <p><strong>Example #1 openssl_csr_export() 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$subject&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"commonName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"example.com"</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">$private_key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_pkey_new</span><span style="color: #007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"private_key_bits"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2048</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"private_key_type"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">OPENSSL_KEYTYPE_RSA</span><span style="color: #007700">,<br />));<br /></span><span style="color: #0000BB">$configargs&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'digest_alg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'sha256WithRSAEncryption'<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$csr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_csr_new</span><span style="color: #007700">(</span><span style="color: #0000BB">$subject</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$private_key</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$configargs</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">openssl_csr_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$csr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$csr_string</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$csr_string</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-csr-export-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="openssl_csr_export_to_file.html" class="function" rel="rdfs-seeAlso">openssl_csr_export_to_file()</a> - 将CSR导出到文件</span></li>
    <li class="member"><span class="function"><a href="openssl_csr_new.html" class="function" rel="rdfs-seeAlso">openssl_csr_new()</a> - 生成一个 CSR</span></li>
    <li class="member"><span class="function"><a href="openssl_csr_sign.html" class="function" rel="rdfs-seeAlso">openssl_csr_sign()</a> - 用另一个证书签署 CSR (或者本身) 并且生成一个证书</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>